package com.shxy.config;

import com.shxy.common.entity.CustomResult;
import com.shxy.common.entity.JsonResult;
import com.shxy.common.enums.ResultCode;
import com.shxy.common.utils.ResultTool;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 统一异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public CustomResult<String> jsonErrorHandler(HttpServletRequest request, Exception exception) throws Exception {
        return new CustomResult(ResultCode.COMMON_FAIL);
    }
}
